package com.yijiajiao.finance.util;

import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Properties;
import java.util.ResourceBundle;

/**
 * @AUTHOR zhaoming@eduspace
 * @CREATE 2017-05-09-9:21
 */
public class Config {
    private static final ResourceBundle config = ResourceBundle.getBundle("application");
    private static final Properties properties = new Properties();
    static {
        try {
            properties.load(new FileInputStream(config.getString("localConfig")));
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }

    public static final BigDecimal PERCENTAGE = new BigDecimal(Config.getString("percentage"));//教师分成比例
    public static final BigDecimal O_PERCENTAGE = BigDecimal.valueOf(1.00).subtract(PERCENTAGE);//平台分成比例

    private Config() {}

    public static String getString(String key) {
        return properties.getProperty(key);
    }

    public static Integer getInt(String key) {
        return Integer.parseInt(properties.getProperty(key));
    }

    public static String getBaseString(String key){
        return config.getString(key);
    }

    public static Properties getProperties(){
        return properties;
    }
}
